//
//  NetCacheData.h
//  why
//
//  Created by lzy on 16/1/27.
//  Copyright © 2016年 刘赞黄Telen. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSData (CacheDate)
@property (nonatomic, strong) NSDate* cacheDate;
@end

@interface NSDictionary (CacheDateDic)
@property (nonatomic, strong) NSDate* cacheDate;
@end

@interface NSArray (CacheDateArr)
@property (nonatomic, strong) NSDate* cacheDate;
@end

@interface NetCacheData : NSObject

+ (NetCacheData*)shareSingle;

/*------- For NSArray --------*/
- (void)adNetCacheDataWithPort:(NSString *)port
                       baseUrl:(NSString *)baseUrl
                         keyID:(NSString *)keyid
              andResponseArray:(NSArray *)retArr;

- (void)getNetCacheDataWithPort:(NSString *)port
                             baseUrl:(NSString *)baseUrl
                               keyID:(NSString *)keyid
                           completed:(void(^)(NSArray * caArray)) comp;


/*----- For NSDictionary -----*/
- (void)addNetCacheDataWithPort:(NSString *)port
                        baseUrl:(NSString *)baseUrl
                          keyID:(NSString *)keyid
                 andResponseDic:(NSDictionary *)retDic;

- (void)getNetChacheDataWithPort:(NSString *)port
                                   baseUrl:(NSString*)baseUrl
                                     keyID:(NSString *)keyid
                       completed:(void(^)(NSDictionary * caDict)) comp;

/*--------- For NSObject ------------*/
- (void)addNetChacheModelWithPort:(NSString *)port
                     baseUrl:(NSString *)baseUrl
                       keyID:(NSString *)keyid
                            model:(id)model
                        completed:(void(^)(BOOL success)) comp;

- (void)getNetCaCheModelWithPort:(NSString *)port
                            baseUrl:(NSString *)baseUrl
                              keyID:(NSString *)keyid
                       completed:(void(^)(id obj)) comp;
/*----------- Base Method (For NSdata)----------*/
//添加对应缓存
- (void)addNetCacheDataWithPort:(NSString *)port            //接口string
                        baseUrl:(NSString *)baseUrl         //baseURl string
                          keyID:(NSString *)keyid           //标识 string
                andResponseData:(NSData *)responseData;     //responseData
//得到对应缓存
- (void)getNetCaCheDataWithPort:(NSString *)port
                            baseUrl:(NSString *)baseUrl
                              keyID:(NSString *)keyid
                      completed:(void(^)(NSData * caData)) comp;

//删除对应缓存
- (void)cleanNetCacheDataWithPort:(NSString *)port
                          baseUrl:(NSString*)baseUrl
                            keyID:(NSString *)keyid
                        completed:(void(^)(BOOL success)) comp;

//删除所有缓存
- (void)cleanAllNetCache_completed:(void(^)(BOOL success)) comp;;


//返回hash字符串
- (NSString *)getFileNameWithPort:(NSString*)port BaseUrl:(NSString*)baseUrl KeyId:(NSString *)keyId;
@end
